$(function () {

});

function login() {
    var username = $("#username").val();
    var password = $("#password").val();
    if(username === ""){
        alert("用户名不能为空");
        return false;
    }
    if(username !== "" && password === ""){
        alert("密码不能为空");
        return false;
    }
    $.ajax({
        url: '/webapi/user/login',
        data: {'username':username, 'password':password},
        method: "get",
        success:function (rs) {
            if(rs.code >= 0){
                window.location.href="/index";
            }else{
                alert("用户名或密码错误！");
            }
        } // end of success
    })//end of ajax
    return false;
}